<%@ include file="/WEB-INF/pages/common/taglibs.jsp" %>
<%@ include file="/WEB-INF/pages/common/checkpermission.jsp" %>
<%@ include file="/WEB-INF/pages/cases/case2/checkCase2Permission.jsp" %>
<codelookup:codeCollection id="deptList" codeType="DEPT_LIST"/>

<script type="text/javascript">
    function searchRecord() {
        $("td").removeClass("showErrorClass");
        submitForm("searchForm", "search.action");
        return false;

    }

    function addRecord() {
        submitForm("searchForm", "viewAdd.action");
    }

    function updateRecord(recordName) {
        var currentForm = document.forms["searchForm"];
        currentForm.elements["caseTwoModel.selectId"].value = recordName;
        submitForm("searchForm", "view.action");
    }


    function deleteRecord() {
        if (!atLeastOneRecordChecked('searchFormDiv')) {
            alert('<s:text name="label.select.atleast.one.record"/>');
        } else {
            if (window.confirm('<s:text name="label.confirm.delete"/>')) {
                submitForm("searchForm", "delete.action");
            }
        }
    }

    function back() {
        submitForm("searchForm", "../clientSummary.action");
    }

</script>
<div id='searchFormDiv'>
    <s:form name="searchForm" action="">
    <s:hidden name="caseTwoModel.selectId" value=""/>
    <table align="center" cellpadding="0" cellspacing="0" class="body_content full_width">
        <tr>
            <td align="left" valign="bottom" class="main_page_content_icon" width="4%">
                <img src='<c:url value="/images/body-icon_check.gif"/>' width="29" height="44">
            </td>
            <td valign="bottom" class="page_title_bg" width="96%"><span class="page_title"><s:text
                    name="label.case.select.title2"/></span></td>
        </tr>
        <tr>
            <td class="subcontent">&nbsp;</td>
            <td class="subcontent">
                <table class="sectionBorder" width="100%">
                    <s:if test='#attr.user.userRole=="A"'>
                        <tr>
                            <td class="form_label_padded" width="10%" nowrap><s:text name='label.deptId'/></td>
                            <td class="form_label_padded" width="2%">:</td>
                            <td class="txtData" align="left">
                                <s:select list="#attr.deptList" name="searchTO.deptId" listKey="codeId"
                                          listValue="codeDesc" headerKey="0" headerValue=""/>
                            </td>
                        </tr>
                        </s:if>
                    <tr>
                        <td class="form_label_padded" width="10%" nowrap><s:text name='label.dateFrom'/></td>
                        <td class="form_label_padded" width="2%">:</td>
                        <td class="txtData" align="left">
                            <monitor:date name="searchTO.dateFrom"/>
                        </td>
                    </tr>
                    <tr>
                        <td class="form_label_padded" width="10%" nowrap><s:text name='label.dateTo'/></td>
                        <td class="form_label_padded" width="2%">:</td>
                        <td class="txtData" align="left">
                            <monitor:date name="searchTO.dateTo"/>
                        </td>
                    </tr>
                    <tr>
                        <td class="txtData" colspan="6">
                            <input type="button" class="button" value="<s:text name='label.search'/>"
                                   onclick="searchRecord();">
                            <input type="button" class="button" value="<s:text name='label.add'/>"
                                   onclick="addRecord();">
                            <s:if test='#attr.user.userRole=="A"'>
                                <input type="button" class="button" value="<s:text name='label.delete'/>"
                                       onclick="deleteRecord();">
                            </s:if>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="6">
                            <display:table name="helper" form="searchForm" uid="row" action="search.action">
                                <display:column titleKey="label.seq" width="3%">
                                    <s:property
                                            value="%{#attr.row_rowNum+(helper.pageNumber-1)*helper.objectsPerPage}"/>
                                </display:column>
                                <display:column width="2%">
                                    <s:checkbox name="resultList[%{#attr.row_rowNum-1}].selectId"
                                                fieldValue="%{#attr.row.caseTwoId}"/>
                                </display:column>
                                <display:column titleKey="label.deptId" sortable="true" sortProperty="DEPT_ID"
                                                width="22%">
                                    <a href="javascript:updateRecord('<s:property value="%{#attr.row.caseTwoId}"/>')">
                                        <codelookup:codeDesc codeType="DEPT_LIST" codeId="${row.deptId}"/>
                                    </a>
                                </display:column>
                                <display:column titleKey="label.casetwo.infoSourcer" sortable="true"
                                                sortProperty="INFO_SOURCE" width="18%">
                                    <s:property value="%{#attr.row.infoSourcer}"/>
                                </display:column>
                                <display:column titleKey="label.casetwo.dutyOfficer" sortable="true"
                                                sortProperty="DUTY_OFFICER" width="18%">
                                    <s:property value="%{#attr.row.dutyOfficer}"/>
                                </display:column>
                                <display:column titleKey="label.casetwo.workPosition" sortable="true"
                                                sortProperty="WORK_POSITION" width="18%">
                                    <s:property value="%{#attr.row.workPosition}"/>
                                </display:column>
                                <display:column titleKey="label.create.date" sortable="true" sortProperty="CREATE_DATE"
                                                width="18%">
                                    <s:property value="%{#attr.row.createDt}"/>
                                </display:column>
                            </display:table>
                        </td>
                    </tr>
                </table>
                <table class="sectionBorder" width="100%">
                    <tr>
                        <td class="txtData" align="left" width="100%">
                            <input type="button" class="button" value="<s:text name='label.back'/>" onclick="back();">
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        </s:form>
</div>
